Example #1
0
        public DataTable getDepDetailByEnd(string strDepName,string strFromTime,string strEndTime)
        {
            try
            {
                string strTime1=strFromTime;
                string strTime2=strEndTime;

                DataTable dtDetail=new DataTable();

                int i=0;
                DateTime dtFrom=DateTime.Parse(strFromTime);
                DateTime dtTo=DateTime.Parse(strEndTime);

            int 	iMonth=(dtTo.Year-dtFrom.Year)*12+dtTo.Month-dtFrom.Month;//new add for desc

                //while(dtFrom.AddMonths(i)<=dtTo)		//new delete for desc
                for(i=iMonth;i>=0;i--)//new add for desc
                {
                    if(i==0)
                    {
                        string strFromEx=strFromTime;
                        strFromTime=string.Format("{0}-{1}-1 23:59",dtFrom.Year.ToString(),dtFrom.Month.ToString());
                        dtFrom=DateTime.Parse(strFromTime);
                        dtFrom=dtFrom.AddMonths(1).AddDays(-1);

                        string strEndEx=string.Format("{0}-{1}-{2} 23:00",dtFrom.Year.ToString(),dtFrom.Month.ToString(),dtFrom.Day.ToString());
                        if(DateTime.Parse(strEndEx)>=dtTo)
                        {
                            strEndEx=dtTo.ToString();
                        }
                        frmReport frmRep=new frmReport();
                        DataTable dtRet=new DataTable();
                        frmRep.detailRepDep(ref dtRet,strFromEx,strEndEx,strDepName);
                    this.clearNullDr(ref dtRet);
                        if(dtRet.Rows.Count==0)
                        {

                        }
                        else
                        {
                            this.addSum1(ref dtRet,-1,strDepName,"�ϼ�");
                            BengZhan.comReport.CReports.copyDt(dtRet,ref dtDetail);
                        }
                    }
                    else
                    {
                        string strFromEx=string.Format("{0}-{1}-1",dtFrom.AddMonths(i).Year,dtFrom.AddMonths(i).Month);
                        //dtFrom=DateTime.Parse(strFromEx);

                        DateTime dtTemp=DateTime.Parse(strFromEx);

                        string strEndEx=string.Format("{0}-{1}-{2} 23:59",dtTemp.Year.ToString(),dtTemp.Month.ToString(),dtTemp.AddMonths(1).AddDays(-1).Day);
                        if(DateTime.Parse(strEndEx)>=dtTo)
                        {
                            strEndEx=dtTo.ToString();
                        }
                        frmReport frmRep=new frmReport();
                        DataTable dtRet=new DataTable();
                        frmRep.detailRepDep(ref dtRet,strFromEx,strEndEx,strDepName);
                        this.clearNullDr(ref dtRet);
                        if(dtRet.Rows.Count==0)
                        {
                        }
                        else
                        {
                            this.addSum1(ref dtRet,-1,strDepName,"�ϼ�");
                            BengZhan.comReport.CReports.copyDt(dtRet,ref dtDetail);
                        }
                    }
                    //i++;
                }

                this.addSumEx1(ref dtDetail,-1,strDepName);

                return dtDetail;

            }

            catch(Exception ex)

            {
                MessageBox.Show(ex.ToString());
                return null;
            }
        }
Example #2
0
        public DataTable getDepDetailByEnd1(string strDepName,string strFromTime,string strEndTime)
        {
            try
            {
                string strTime1=strFromTime;
                string strTime2=strEndTime;

                DataTable dtDetail=new DataTable();

                int i=0;
                DateTime dtFrom=DateTime.Parse(strFromTime);
                DateTime dtTo=DateTime.Parse(strEndTime);

                //int 	iMonth=(dtTo.Year-dtFrom.Year)*12+dtTo.Month-dtFrom.Month;//new add for desc

                        frmReport frmRep=new frmReport();
                        DataTable dtRet=new DataTable();
                        frmRep.detailRepDep(ref dtRet,strFromTime,strEndTime,strDepName);

                        this.clearNullDr(ref dtRet);
                if(dtRet==null)
                {
                    return null;
                }
                        if(dtRet.Rows.Count==0)
                        {

                        }
                        else
                        {
                            this.addSum1(ref dtRet,-1,strDepName,"�ϼ�");
                            BengZhan.comReport.CReports.copyDt(dtRet,ref dtDetail);
                        }

                this.addSumEx1(ref dtDetail,-1,strDepName);

                return dtDetail;
            }
            catch(Exception ex)

            {
                MessageBox.Show(ex.ToString());
                return null;
            }
        }
Example #3
0
        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());
            }
        }