⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page_standard_append.cpp

📁 C# 教学示例程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  case 8:
	  strName="圆周齿数 ";m_zn_cutter.SetFocus();return;
  case 9:
	  strName="前角";m_qian_angle_cutter.SetFocus();return;
  case 10:
	  strName="后角";m_hou_angle_cutter.SetFocus();return;
  case 11:
	  strName="滚刀头数";m_tou_n_cutter.SetFocus();return;
  case 12:
	  strName="容屑槽角";m_chao_angle_cutter.SetFocus();return;
  }
  }
  }
}

void CPage_Standard_Append::OnBUTTONcompute() 
{
	(CButton *)GetDlgItem(IDC_BUTTON_to_database)->EnableWindow(FALSE);
	clear_list();
	setparazero();
    check();
	if(para_check_symbol==1) {MessageBox(strName+"不能为空!","警告",MB_ICONWARNING+MB_OK);return;;}
    this->UpdateData(TRUE);	
	char info[100];
	
	set_para();
	gear_aided_para();
	cutter_para();	
	sprintf(info,"侧后角αc=%f,条件αc>3度\n",c_ac);

   if(MessageBox(info,"提示",MB_ICONQUESTION+MB_OKCANCEL)==IDOK)
	{
		(CButton *)GetDlgItem(IDC_BUTTON_to_database)->EnableWindow(TRUE);
	}
	else
	{
        (CButton *)GetDlgItem(IDC_BUTTON_to_database)->EnableWindow(FALSE);
	}
    list_result();
}

void CPage_Standard_Append::clear_list()
{
	//m_list_result.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	//m_list_result.SetExtendedStyle(LVS_EX_GRIDLINES);
	m_list_result.DeleteAllItems();
	while(m_list_result.DeleteColumn(0));
    UpdateWindow();
}

void CPage_Standard_Append::clear_list_gear()
{
	//m_list_result.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	//m_list_result.SetExtendedStyle(LVS_EX_GRIDLINES);
	m_list_data_gear.DeleteAllItems();
	while(m_list_data_gear.DeleteColumn(0));
    UpdateWindow();
}

void CPage_Standard_Append::list_result()
{
	
	CString str;
	CString column[]={"齿轮零件号","刀具号","滚刀外径Deg","孔径di","全长L","圆周齿数Zk","铲背量K","第二铲背量K1","齿顶高heg","齿全高Hg","容屑槽深度H","槽底半径r","容屑槽角θ","分圆直径Dfg","分圆螺旋升角λf","轴向齿距Txg","轴向齿厚Sxg","轴向齿形角αxg","齿顶圆角半径r1","齿根圆角半径r2"};
    int nWidth;
	for(int i=0;i<20;i++)
	{
    nWidth=column[i].GetLength()+100;
    m_list_result.InsertColumn(i,column[i],LVCFMT_RIGHT,nWidth);
	}

	CString strValue[20];
	this->UpdateData();
	strValue[0].Format("%s",m_num_gear_v);
    strValue[1].Format("%s",m_num_cutter_v);
	strValue[2].Format("%f",c_deg);
    strValue[3].Format("%f",c_di);
	strValue[4].Format("%f",c_l);
	strValue[5].Format("%d",c_zk);
	strValue[6].Format("%f",c_k);
	strValue[7].Format("%f",c_k1);
	strValue[8].Format("%f",c_heg);
	strValue[9].Format("%f",c_hg);
	strValue[10].Format("%f",c_h);
	strValue[11].Format("%f",c_r);
	strValue[12].Format("%f",c_o);
	strValue[13].Format("%f",c_dfg);
	strValue[14].Format("%f",c_helicf);
	strValue[15].Format("%f",c_txg);
	strValue[16].Format("%f",c_sxg);
	strValue[17].Format("%f",c_axg);
    strValue[18].Format("%f",r1);
	strValue[19].Format("%f",r2);

	int j=1;
	int nCount=0;
	m_list_result.InsertItem(nCount,strValue[0]);
	while(j<21)
	{
	m_list_result.SetItemText(nCount,j,strValue[j]);
	j++;
	}
}

void CPage_Standard_Append::cutter_para()
{
	/*输入c_deg,c_di,c_l,c_rq,c_ae,c_n,c_o*/	
    c_deg=m_dia_cutter_v;
    c_di=m_hole_dia_cutter_v;
    c_l=m_long_cutter_v;
    c_zk=m_zn_cutter_v;
    c_rq=m_qian_angle_cutter_v;
    c_ae=m_hou_angle_cutter_v;
    c_n=m_tou_n_cutter_v;
    c_o=m_chao_angle_cutter_v;
 
    c_e=c_deg*sin(c_rq*PI/180)/2;
    c_k=floor((PI*c_deg*tan(c_ae*PI/180)/c_zk)*2+0.5)/2;
    c_ac=atan(c_zk*c_k*sin(g_afn*PI/180)/(PI*c_deg))*180/PI;
    c_k1=floor(1.5*c_k*2+0.5)/2;
    c_heg=(gf_df-g_di)/2;
    c_hig=floor(1000*((g_de-gf_df)/2+g_c*g_mn))/1000;
    c_hg=c_heg+c_hig;
    c_h=floor(10*(c_hg+(c_k+c_k1)/2+1))/10;
    c_r=floor(100*PI*(c_deg-c_h)/(10*c_zk)+0.5)/100;
    c_dfg=c_deg-2*c_heg-0.2*c_k;
    c_helicf=asin(g_mn*c_n/c_dfg)*180/PI;
    if(c_helicf>5)
    c_bk=c_helicf;
    else
    c_bk=0;

    if(c_bk==0)
    c_pk_info="无穷大";
    else
    c_pk=PI*c_dfg/tan(c_bk*PI/180);

    c_tng=g_mn*PI;
    c_txg=c_tng/cos(c_helicf*PI/180);
    c_sng=c_tng-(g_sfn+g_ds);
    c_sxg=c_sng/cos(c_helicf*PI/180);
    c_axg=atan(tan(g_afn*PI/180)/cos(c_helicf*PI/180))*180/PI;
	r1=0.3*g_mn;
	r2=0.3*g_mn;
}

void CPage_Standard_Append::set_para()
{	
    g_mn=m_mn_gear_v;
	g_z=m_zn_gear_v;
	g_afn=m_angle_gear_v;
	g_bf=m_helic_gear_v;
	g_sfn=m_nthick_gear_v;
    g_de=m_top_dia_gear_v;
	g_di=m_bottom_dia_gear_v;
    g_ds=m_margin_gear_v;
	g_z1=m_zn_gear1_v;
	g_de1=m_top_dia_gear1_v;
	g_a=m_centerdist_gear1_v;
	g_c=m_c_gear_v;
	g_c11=0.007*g_mn;
}

void CPage_Standard_Append::gear_aided_para()
{
    gf_ms=g_mn/cos(g_bf*PI/180);
	gf_afs=atan(tan(g_afn*PI/180)/cos(g_bf*PI/180))*180/PI;
	gf_invafs=tan(gf_afs*PI/180)-gf_afs*PI/180;
	gf_df=gf_ms*g_z;
	gf_df1=gf_ms*g_z1;
	gf_db=gf_df*cos(gf_afs*PI/180);
	gf_db1=gf_df1*cos(gf_afs*PI/180);
	gf_Bb=asin(sin(g_bf*PI/180)*cos(g_afn*PI/180))*180/PI;
	if(g_a==gf_df+gf_df1)
	{
      gf_as=gf_afs;
	}
	else
	{
	  gf_as=acos((gf_df+gf_df1)*cos(gf_afs*PI/180)/(2*g_a))*180/PI;
	}
	gf_l=0.5*(sqrt(g_de*g_de-gf_db*gf_db)+sqrt(g_de1*g_de1-gf_db1*gf_db1)-2*g_a*sin(gf_as*PI/180));
	gf_pmin=0.5*sqrt(g_de*g_de-gf_db*gf_db)-gf_l;
	gf_dl=0.05*gf_ms/sin(gf_as*PI/180);
}

void CPage_Standard_Append::init()
{
    m_num_gear.EnableWindow(FALSE);
	m_mn_gear.EnableWindow(FALSE);
	m_zn_gear.EnableWindow(FALSE);
    m_angle_gear.EnableWindow(FALSE);
    m_helic_gear.EnableWindow(FALSE);
    m_nthick_gear.EnableWindow(FALSE);
    m_top_dia_gear.EnableWindow(FALSE);
	m_bottom_dia_gear.EnableWindow(FALSE);
	m_thick_gear.EnableWindow(FALSE);
    m_margin_gear.EnableWindow(FALSE);
    
	m_num_gear.SetWindowText("");
	m_mn_gear.SetWindowText("");
	m_zn_gear.SetWindowText("");
    m_angle_gear.SetWindowText("");
    m_helic_gear.SetWindowText("");
    m_nthick_gear.SetWindowText("");
    m_top_dia_gear.SetWindowText("");
	m_bottom_dia_gear.SetWindowText("");
	m_thick_gear.SetWindowText("");
    m_margin_gear.SetWindowText("");
    m_c_gear.SetWindowText("");
  
    m_zn_gear1.SetWindowText("");
	m_top_dia_gear1.SetWindowText("");
	m_center_dist_gear1.SetWindowText("");
	m_num_cutter.SetWindowText("");
	m_dia_cutter.SetWindowText("");
	m_hole_dia_cutter.SetWindowText("");
	m_long_cutter.SetWindowText("");
	m_zn_cutter.SetWindowText("");
	m_qian_angle_cutter.SetWindowText("");
	m_hou_angle_cutter.SetWindowText("");
	m_tou_n_cutter.SetWindowText("");
	m_chao_angle_cutter.SetWindowText("");		 
}

void CPage_Standard_Append::writefile()
{
    CString filepathname;
    CFile datefile;
    if(m_list_result.GetSelectedCount()==0)
	{
	MessageBox("对不起,请选择一条参数!","提示",MB_ICONWARNING+MB_OK);
	return;
	}
    CFileDialog filedlg(FALSE,_T("txt"),_T("*.txt"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("文本文件(*.txt)|*.txt|"));
    try
	{
	if(IDOK==filedlg.DoModal())
	{
    filepathname.Format("%s",filedlg.GetPathName());
    datefile.Open(filepathname,CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyNone);
    static char buf[600];
    sprintf(buf,"齿轮零件号=%s,刀具号=%s,滚刀外径 Deg=%f,孔径 di=%f,全长 L=%f,圆周齿数 Zk=%d,铲背量 K=%f,第二铲背量 K1=%f,齿顶高 heg=%f,齿全高 Hg=%f,容屑槽深度 H=%f,槽底半径 r=%f,容屑槽角 θ=%f,分圆直径 Dfg=%f,分圆螺旋升角 λf=%f,轴向齿距 Txg=%f,轴向齿厚 Sxg=%f,轴向齿形角 αxg=%f,齿顶圆角半径 r1=%f,齿根圆角半径r2=%f",m_num_gear_v,m_num_cutter_v,c_deg,c_di,c_l,c_zk,c_k,c_k1,c_heg,c_hg,c_h,c_r,c_o,c_dfg,c_helicf,c_txg,c_sxg,c_axg,r1,r2);
    datefile.WriteHuge(buf,sizeof(buf));
	MessageBox("操作成功!","提示",MB_ICONINFORMATION+MB_OK);
	}
	}
	catch(CException* e)
	{
		e->Delete();
		MessageBox("操作失败!","提示",MB_ICONERROR+MB_OK);
		return;
	}
}

void CPage_Standard_Append::OnBUTTONtofile() 
{
	// TODO: Add your control notification handler code here
	writefile();
}

void CPage_Standard_Append::OnBUTTONtodatabase() 
{
	// TODO: Add your control notification handler code here

    if(m_list_result.GetSelectedCount()==0)
	{
    MessageBox("对不起,请选择一条参数!","提示",MB_ICONWARNING+MB_OK);
    return;
	}
    CString str[20];
    int nItemSel=0;
    nItemSel=m_list_result.GetNextItem(nItemSel-1,LVNI_SELECTED);
    for(int i=0;i<20;i++)
	{
	str[i]=m_list_result.GetItemText(nItemSel,i);
	}
    float strValue[18];
    CString num_gear=str[0];
    CString num_cutter=str[1];
	for(int j=0;j<18;j++)
	{
    strValue[j]=atof(str[j+2].GetBuffer(0));
	}

    CString strsql,strsql_gear;
    extern int symbol;
	if(symbol==0) 
	{   
     strsql.Format("insert into standard_hob_table(齿轮零件号,刀具号,滚刀外径,孔径,全长,圆周齿数,铲背量,第二铲背量,齿顶高,齿全高,容屑槽深度,槽底半径,容屑槽角,分圆直径,分圆螺旋升角,轴向齿距,轴向齿厚,轴向齿形角,齿顶圆角半径,齿根圆角半径) values('%s','%s',%f,%f,%f,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f)",num_gear,num_cutter,strValue[0],strValue[1],strValue[2],(int)strValue[3],strValue[4],strValue[5],strValue[6],strValue[7],strValue[8],strValue[9],strValue[10],strValue[11],strValue[12],strValue[13],strValue[14],strValue[15],strValue[16],strValue[17]);
	}
	else
	{
     strsql.Format("update standard_hob_table set 刀具号='%s',滚刀外径=%f,孔径=%f,全长=%f,圆周齿数=%d,铲背量=%f,第二铲背量=%f,齿顶高=%f,齿全高=%f,容屑槽深度=%f,槽底半径=%f,容屑槽角=%f,分圆直径=%f,分圆螺旋升角=%f,轴向齿距=%f,轴向齿厚=%f,轴向齿形角=%f,齿顶圆角半径=%f,齿根圆角半径=%f where 齿轮零件号='%s'",num_cutter,strValue[0],strValue[1],strValue[2],(int)strValue[3],strValue[4],strValue[5],strValue[6],strValue[7],strValue[8],strValue[9],strValue[10],strValue[11],strValue[12],strValue[13],strValue[14],strValue[15],strValue[16],strValue[17],num_gear);
	}
	strsql_gear.Format("update gear_table set 滚刀齿根与齿轮齿顶的径向间隙系数=%f where 齿轮零件号='%s'",g_c,num_gear);
	try
	{
		if(m_pdatabase->CanUpdate())
		{      
			   m_pdatabase->BeginTrans();
               m_pdatabase->ExecuteSQL(strsql);
		       m_pdatabase->ExecuteSQL(strsql_gear);
			   m_pdatabase->CommitTrans();
		}
		MessageBox("操作成功!","提示",MB_ICONINFORMATION+MB_OK);
	}
	catch(CDBException* e)
	{	
		e->Delete();
		m_pdatabase->Rollback();
	    MessageBox("操作失败!","提示",MB_ICONERROR+MB_OK);
		return;
	}
	if(symbol==0)
	{
    clear_list_gear();
    IniListAppend();
	clear_list();
	init();
	}
	(CButton *)GetDlgItem(IDC_BUTTON_to_database)->EnableWindow(FALSE);	
}

void CPage_Standard_Append::OnDestroy() 
{
	CPropertyPage::OnDestroy();
	
	// TODO: Add your message handler code here
	delete m_pset;
	delete m_pdatabase;
}


void CPage_Standard_Append::OnCancel() 
{
	// TODO: Add your specialized code here and/or call the base class	
	CPropertyPage::OnCancel();
}

void CPage_Standard_Append::OnOK() 
{
	// TODO: Add your specialized code here and/or call the base class
	CPropertyPage::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -