//��λ public DataTable getStaticRepDepEx(string strDepName,string strFromTime,string strEndTime) { try { string strSql=string.Format("select wellName from tbWell where depName='{0}' order by wellNo",strDepName); DataTable dtWell=new DataTable(); BengZhan.CDBConnection.getDataTable(ref dtWell,strSql,"dt"); DataTable dtShDep=new DataTable(); //�ϼ��� // for(int i=0;i<dtWell.Rows.Count;i++) // { // string strWellName=dtWell.Rows[i]["wellName"].ToString().Trim(); // // CReportDll.comReport.newRep.cDealReport cdr=new cDealReport(); // string[] strTime=null; // // DataTable dtSh= cdr.getStaticRepByE(strWellName,strFromTime,strEndTime,ref strTime); // // if(strTime==null) // { // continue; // } // // BengZhan.comReport.CReports.copyDt(dtSh,ref dtShDep); // } // // if(dtShDep.Rows.Count==0) // { // return null; // } // // this.addSum(ref dtShDep,""); // // int iCount=dtShDep.Rows.Count-1; // for(int i=0;i<iCount;i++) // { // dtShDep.Rows.RemoveAt(0); // } // // if(dtShDep.Rows.Count==0) // { // return null; // } // // dtShDep.Rows[0][0]=strDepName+"�ϼ�"; // dtShDep.Rows[0]["time"]=strEndTime; //վ��ϸ for(int i=0;i<dtWell.Rows.Count;i++) { string strWellName=dtWell.Rows[i]["wellName"].ToString().Trim(); CReportDll.comReport.newRep.cDealReport cdr=new cDealReport(); string[] strTime=null; DataTable dtSh= cdr.getStaticRep(strWellName,strFromTime,strEndTime,ref strTime); if(strTime==null) { continue; } BengZhan.comReport.CReports.copyDt(dtSh,ref dtShDep); } if(dtShDep.Rows.Count==0) { return null; } this.addSum(ref dtShDep,-1,strDepName); this.clearTime(ref dtShDep,strFromTime); return dtShDep; } catch(Exception ex) { MessageBox.Show(ex.ToString()); return null; } }
private void button2_Click(object sender, System.EventArgs e) { try { this.clearLsv(); this.iniListV(this.listView1,2); DateTime dt=this.dtp2.Value; string strEndTime=string.Format("{0} {1}:00:00",dt.ToShortDateString(),this.cmbH.Text.Trim()); string strTime=""; if(this.lblName.Text.IndexOf("վ")>=0) { //���վ CReportDll.comReport.newRep.cDealReport cdr=new cDealReport(); DataTable dtSh= cdr.getStaticRepEx(this.txtZhan.Text.Trim(),strEndTime,ref strTime); if(dtSh==null) { return; } if(dtSh.Rows.Count==0) { return; } this.paintList(this.listView1,2,dtSh); } if(this.lblName.Text.IndexOf("��λ")>=0) { string strDepName=this.txtZhan.Text.Trim(); CReportDll.comReport.newRep.cDealReport cdr=new cDealReport(); DataTable dtSh= cdr.getStaticRepDepEx(this.txtZhan.Text.Trim(),strEndTime); if(dtSh==null) { return; } if(dtSh.Rows.Count==0) { return; } this.paintList(this.listView1,2,dtSh); } if(this.lblName.Text.IndexOf("����")>=0) { string strCountryName=this.txtZhan.Text.Trim(); CReportDll.comReport.newRep.cDealReport cdr=new cDealReport(); DataTable dtSh= cdr.getStaticRepCountry(this.txtZhan.Text.Trim(),strEndTime); if(dtSh==null) { return; } if(dtSh.Rows.Count==0) { return; } this.paintList(this.listView1,2,dtSh); } this.groupBox1.Text=string.Format("��ˮ����ͳ�Ʊ� ��ֹʱ��:{0}",strEndTime); this.paintTime(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } }
private void showAmountDetail() { try { if((this.groupBox3.Text.IndexOf("���վ")>=0)&&(this.groupBox3.Text.IndexOf("ʱ�䷶Χ")>=0)) { //��ʾվ�� string strTitle=this.groupBox3.Text.Trim(); strTitle=this.replace2str(strTitle); // string[] strsTitle=strTitle.Split(' '); string strZhanName=""; string strTime1=""; string strTime2=""; int iDexZhan=strTitle.IndexOf("���վ"); int iDexTime=strTitle.IndexOf("ʱ�䷶Χ"); strZhanName=strTitle.Substring(iDexZhan,(iDexTime-iDexZhan)).Trim(); strZhanName=strZhanName.Substring(4); strTime1=strTitle.Substring(iDexTime).Trim(); strTime1=strTime1.Substring(5); string[] strsTime=strTime1.Split('��'); strTime1=strsTime[0].Trim(); strTime2=strsTime[1].Trim(); DataTable dtDetail=new DataTable(); string strSql=string.Format("select wellNo from tbWell where wellName='{0}'",strZhanName); string strZhanNo=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); if(BengZhan.comReport.CReports.getDtDetailReportDay(strZhanNo,strTime1,strTime2,ref dtDetail)==false) { return; } if(dtDetail.Rows.Count<=1) { return; } dtDetail.Columns.Add("leftAmountIC"); dtDetail.Columns.Add("usedMony");; for(int i=0;i<dtDetail.Rows.Count;i++) { string strTime=dtDetail.Rows[i]["time"].ToString().Trim(); string strWellName=dtDetail.Rows[i]["wellName"].ToString().Trim(); string strAllAmount=dtDetail.Rows[i]["allAmount"].ToString().Trim(); strSql=string.Format("select max(cast(allSalAmount as decimal(19,2))) from tbSal,tbWell where tbWell.wellNo=tbSal.wellNo and wellName='{0}' and time<='{1}'",strWellName,strTime); string strAllSalAmount=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); if((strAllSalAmount==null)||strAllSalAmount.Trim()=="") { continue; } strSql=string.Format("select price1 from tbWell where wellName='{0}'",strWellName); string strPrice=BengZhan.CDBConnection.ExecuteScalar(strSql); double dPrice=double.Parse(strPrice); double dAllSalAmount=double.Parse(strAllSalAmount); double dAllAmount=double.Parse(strAllAmount); double dAllMony=dAllAmount*dPrice; double dLeftAmount=dAllSalAmount-dAllAmount; dtDetail.Rows[i]["leftAmountIC"]=dLeftAmount.ToString(); dtDetail.Rows[i]["usedMony"]=dAllMony.ToString(); } this.paintList(this.listView4,5,dtDetail); } if((this.groupBox3.Text.IndexOf("��λ")>=0)&&(this.groupBox3.Text.IndexOf("ʱ�䷶Χ")>=0)) { //��ʾվ�� string strTitle=this.groupBox3.Text.Trim(); strTitle=this.replace2str(strTitle); // string[] strsTitle=strTitle.Split(' '); string strDepName=""; string strTime1=""; string strTime2=""; int iDexZhan=strTitle.IndexOf("��λ"); int iDexTime=strTitle.IndexOf("ʱ�䷶Χ"); strDepName=strTitle.Substring(iDexZhan,(iDexTime-iDexZhan)).Trim(); strDepName=strDepName.Substring(3); strTime1=strTitle.Substring(iDexTime).Trim(); strTime1=strTime1.Substring(5); string[] strsTime=strTime1.Split('��'); strTime1=strsTime[0].Trim(); strTime2=strsTime[1].Trim(); DataTable dtDetail=new DataTable(); frmReport frmRep=new frmReport(); frmRep.detailRepDep(ref dtDetail,strTime1,strTime2,strDepName); dtDetail.Columns.Add("leftAmountIC"); dtDetail.Columns.Add("usedMony");; for(int i=0;i<dtDetail.Rows.Count;i++) { string strTime=dtDetail.Rows[i]["time"].ToString().Trim(); string strWellName=dtDetail.Rows[i]["wellName"].ToString().Trim(); string strAllAmount=dtDetail.Rows[i]["allAmount"].ToString().Trim(); string strSql=string.Format("select price1 from tbWell where wellName='{0}'",strWellName); string strPrice=BengZhan.CDBConnection.ExecuteScalar(strSql); if((strPrice==null)||strPrice.Trim()=="") { continue; } strSql=string.Format("select max(cast(allSalAmount as decimal(19,2))) from tbSal,tbWell where tbWell.wellNo=tbSal.wellNo and wellName='{0}' and time<='{1}'",strWellName,strTime); string strAllSalAmount=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); if((strAllSalAmount==null)||strAllSalAmount.Trim()=="") { continue; } double dPrice=double.Parse(strPrice); double dAllSalAmount=double.Parse(strAllSalAmount); double dAllAmount=double.Parse(strAllAmount); double dAllMony=dAllAmount*dPrice; double dLeftAmount=dAllSalAmount-dAllAmount; dtDetail.Rows[i]["leftAmountIC"]=dLeftAmount.ToString(); dtDetail.Rows[i]["usedMony"]=dAllMony.ToString(); } this.paintList(this.listView4,5,dtDetail); } if((this.groupBox3.Text.IndexOf("���վ")>=0)&&(this.groupBox3.Text.IndexOf("��ֹʱ��")>=0)) { //��ʾվ�� string strTitle=this.groupBox3.Text.Trim(); strTitle=this.replace2str(strTitle); // string[] strsTitle=strTitle.Split(' '); string strZhanName=""; string strTime1=""; string strTime2=""; int iDexZhan=strTitle.IndexOf("���վ"); int iDexTime=strTitle.IndexOf("��ֹʱ��"); strZhanName=strTitle.Substring(iDexZhan,(iDexTime-iDexZhan)).Trim(); strZhanName=strZhanName.Substring(4); strTime1=strTitle.Substring(iDexTime).Trim(); strTime1=strTime1.Substring(5); string strSql=string.Format("select time from tbMinTime"); strTime2=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); string strTime3=""; strTime3=strTime1; strTime1=strTime2; strTime2=strTime3; // string strTime2=BengZhan.CDBConnection. //string[] strsTime=strTime1.Split('��'); // strTime1=strsTime[0].Trim(); //strTime2=strsTime[1].Trim(); DataTable dtDetail=new DataTable(); strSql=string.Format("select wellNo from tbWell where wellName='{0}'",strZhanName); string strZhanNo=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); if(BengZhan.comReport.CReports.getDtDetailReportDay(strZhanNo,strTime1,strTime2,ref dtDetail)==false) { return; } if(dtDetail.Rows.Count<=1) { return; } dtDetail.Columns.Add("leftAmountIC"); // dtDetail.Columns.Add("usedMony");; // for(int i=0;i<dtDetail.Rows.Count;i++) // { // string strTime=dtDetail.Rows[i]["time"].ToString().Trim(); // string strWellName=dtDetail.Rows[i]["wellName"].ToString().Trim(); // string strAllAmount=dtDetail.Rows[i]["allAmount"].ToString().Trim(); // // strSql=string.Format("select max(cast(allSalAmount as decimal(19,2))) from tbSal,tbWell where tbWell.wellNo=tbSal.wellNo and wellName='{0}' and time<='{1}'",strWellName,strTime); // string strAllSalAmount=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); // // if((strAllSalAmount==null)||strAllSalAmount.Trim()=="") // { // continue; // } // // strSql=string.Format("select price1 from tbWell where wellName='{0}'",strWellName); // string strPrice=BengZhan.CDBConnection.ExecuteScalar(strSql); // double dPrice=double.Parse(strPrice); // // double dAllSalAmount=double.Parse(strAllSalAmount); // double dAllAmount=double.Parse(strAllAmount); // double dAllMony=dAllAmount*dPrice; // double dLeftAmount=dAllSalAmount-dAllAmount; // // dtDetail.Rows[i]["leftAmountIC"]=dLeftAmount.ToString(); // dtDetail.Rows[i]["usedMony"]=dAllMony.ToString(); // } this.paintList(this.listView4,5,dtDetail); } if((this.groupBox3.Text.IndexOf("��λ")>=0)&&(this.groupBox3.Text.IndexOf("��ֹʱ��")>=0)) { //��ʾվ�� string strTitle=this.groupBox3.Text.Trim(); strTitle=this.replace2str(strTitle); // string[] strsTitle=strTitle.Split(' '); string strDepName=""; string strTime1=""; string strTime2=""; int iDexZhan=strTitle.IndexOf("��λ"); int iDexTime=strTitle.IndexOf("��ֹʱ��"); strDepName=strTitle.Substring(iDexZhan,(iDexTime-iDexZhan)).Trim(); strDepName=strDepName.Substring(3); strTime1=strTitle.Substring(iDexTime).Trim(); strTime1=strTime1.Substring(5); string strSql=string.Format("select time from tbMinTime"); strTime2=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); string strTime3=""; strTime3=strTime1; strTime1=strTime2; strTime2=strTime3; cDealReport cdr=new cDealReport(); DataTable dtDetail=cdr.getDepDetailByEnd(strDepName,strTime2); if(dtDetail==null) { return; } this.paintList(this.listView4,5,dtDetail); this.groupBox4.Text=string.Format("��ˮ��ϸ�� ��λ:{0} ��ֹʱ��:{1}",strDepName,strTime2); } } catch(Exception ex) { MessageBox.Show(ex.ToString()); } }
private void showManaDatas(DataTable dtRep) { try { if(dtRep==null) { return; } if(dtRep.Rows.Count>0) { for(int j=0;j<dtRep.Rows.Count;j++) { //this.m_dtAllSa.Rows.Clear(); DataRow dr=this.m_dtAllSa.NewRow(); string strTime=dtRep.Rows[j]["time"].ToString().Trim(); int inDex=strTime.LastIndexOf(":"); strTime=strTime.Substring(0,inDex); //strSql=string.Format("select wellNo from tbWell where wellName='{0}'",strWellName); string strWellName=dtRep.Rows[j]["name"].ToString().Trim(); string strWellNo=dtRep.Rows[j]["watNo"].ToString().Trim(); string strSql=string.Format("select allSalAmount from tbSal where time=(select max(time) from tbSal where wellNo='{0}' and time<='{1}') and wellNo='{0}'",strWellNo,strTime); string strAllSalAmount=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); strSql=string.Format("select price1 from tbWell where wellNo='{0}'",strWellNo); string strPrice=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); if(strAllSalAmount.Trim()=="") { strAllSalAmount="0"; } strSql=string.Format("select depName from tbWell where wellName='{0}'",strWellName); string strDepName=BengZhan.CDBConnection.ExecuteScalar(strSql).Trim(); double dAllSalAmount=double.Parse(strAllSalAmount); double dAllSalMony=dAllSalAmount*double.Parse(strPrice); double dLeftIC=dAllSalAmount-double.Parse(dtRep.Rows[j]["allAmount"].ToString()); double dLeftMony=dLeftIC*double.Parse(strPrice); double dAllAmount=double.Parse(dtRep.Rows[j]["allAmount"].ToString()); double dAllUsedMony=dAllAmount*double.Parse(strPrice); dr["wellName"]=strWellName; dr["leftAmount"]=dLeftIC.ToString(); dr["leftMony"]=dLeftMony.ToString(); dr["allMony"]=dAllSalMony.ToString(); dr["allBuyAmount"]=dAllSalAmount.ToString(); dr["allUsedMony"]=dAllUsedMony.ToString(); dr["allAmount"]=dtRep.Rows[j]["allAmount"].ToString(); dr["time"]=strTime; this.m_dtAllSa.Rows.Add(dr); cDealReport cdr=new cDealReport(); this.removeSum(ref this.m_dtAllSa); string strTimeEx=cDealReport.getMaxTime(this.m_dtAllSa); cdr.addSum(ref this.m_dtAllSa,-1,strDepName); //this.m_dtAllSa.Rows[0]["time"]=strTimeEx; this.paintList(this.listView1, 2,this.m_dtAllSa); this.paintTime(); //this.paintSumRowLsv2(); for(int i=0;i<this.m_dtSended.Rows.Count;i++) { string strWellNameEx=this.m_dtSended.Rows[i]["zhanName"].ToString().Trim(); if(strWellNameEx==strWellName.Trim()) { this.m_dtSended.Rows.RemoveAt(i); i--; } } if(this.m_dtSended.Rows.Count==0) { this.lblInfo.Text=""; this.allReved(); } } } } catch(Exception ex) { cSaveErr.CSaveErr.msgboxErr(ex.ToString()); } }
private void listView1_SelectedIndexChanged_2(object sender, System.EventArgs e) { try { if(this.listView1.SelectedItems.Count==0) { return; } string strZhanName=this.listView1.SelectedItems[0].Text.Trim(); int iCount=this.listView1.Items[0].SubItems.Count; string strTime=this.listView1.SelectedItems[0].SubItems[iCount-1].Text.Trim(); if(strZhanName.IndexOf("�ϼ�")>=0) { strZhanName=strZhanName.Replace("�ϼ�",""); //��λ DataTable dtAllSalesDep=new DataTable(); cDealReport cdr=new cDealReport(); dtAllSalesDep=cdr.getAllSalesDep(strZhanName,strTime); CReportDll.comReport.newRep.cDealReport.changeDataType(ref dtAllSalesDep); this.paintList(this.listView3,3,dtAllSalesDep); this.groupBox3.Text="��ˮ��ϸ��"+" "+"��λ:"+strZhanName+" "+"��ֹʱ��:"+strTime; } else { iCount=this.listView1.Items[0].SubItems.Count; iCount--; strTime=this.listView1.SelectedItems[0].SubItems[iCount].Text.Trim(); string strName=this.listView1.SelectedItems[0].SubItems[0].Text.Trim(); if(strTime.IndexOf("��")>=0) { string[] strsTime=strTime.Split('��'); strTime=strsTime[1].Trim(); } string strSql=string.Format("select wellName,cast(price as nvarchar(10)) price,salMony,salAmount,time,salPer,allSalAmount as allSalAmountAfter,(allSalAmount-salAmount) as allSalAmountBefore from tbWell,tbSal where tbSal.wellNo=tbWell.wellNo and wellname='{0}' and time<='{1}' order by time",strName,strTime); DataTable dtDetail=new DataTable(); BengZhan.CDBConnection.getDataTable(ref dtDetail,strSql,"dt"); this.addSum(ref dtDetail); this.paintList(this.listView3,3,dtDetail); this.groupBox3.Text=string.Format("��ˮ��ϸ�� ���վ:{1} ��ֹʱ��:{0}",strTime,strName); //this.m_strTitle3="���վ��"+strName; } this.showAmountDetail(); this.groupBox3.Text=string.Format("��ˮ��ϸ�� ��ֹʱ��:{0}",strTime); this.groupBox4.Text=string.Format("��ˮ��ϸ�� ��ֹʱ��:{0}",strTime); //Console.WriteLine(this.groupBox3.Text); } catch(Exception ex) { cSaveErr.CSaveErr.msgboxErr(ex.ToString()); } }