Example #1
0
        public DeliveryResutl Statistic(string customer, DateTime sStart, DateTime sEnd, string specifications, string goodname)
        {
            DeliveryResutl result = new DeliveryResutl();

            string strSql1 = "SELECT SUM(b.lenght*b.discnum), SUM(b.discnum),SUM(b.totalprice),SUM(b.weight) FROM ct_deliverynote a,ct_deliveryitem b where a.noteid=b.noteid and a.deliverdate>='" + sStart.ToString() + "' and a.deliverdate<='" + sEnd.ToString() + "'";

            if (customer.Length > 0)
            {
                strSql1 += " and a.customer = '" + customer + "'";
            }
            if (goodname.Length > 0)
            {
                strSql1 += " and a.goodname = '" + goodname + "'";
            }
            if (specifications.Length > 0)
            {
                strSql1 += " and b.specifications = '" + specifications + "'";
            }

            DataTable dtSum = DMContext.TSqlCommand(strSql1).ToDataTable();

            if (dtSum != null)
            {
                if (dtSum.Rows.Count > 0)
                {
                    result.TotalLength = ControlHelper.Object2Int(dtSum.Rows[0][0]);
                    result.TotalDisc   = ControlHelper.Object2Int(dtSum.Rows[0][1]);
                    result.TotalPrice  = ControlHelper.Object2Double(dtSum.Rows[0][2]);
                    result.TotalWeight = ControlHelper.Object2Double(dtSum.Rows[0][3]);
                }
            }

            return(result);
        }
Example #2
0
 private void RefreshData()
 {
     InitHeader();
     try
     {
         DeliveryDAC    dac       = new DeliveryDAC();
         DeliveryResutl objResult = dac.SelectList(customer.Text.Trim(), dtpStart.Value, dtpEnd.Value, goodname.Text.Trim(), specifications.Text.Trim());
         DataTable      dt        = ControlHelper.ConvertList2DataTable(objResult.Notes);
         dataGridResult.DataSource = dt;
         StatusLabelDisco.Text     = objResult.TotalDisc.ToString();
         StatusLabelLength.Text    = objResult.TotalLength.ToString();
         StatusLabelWeight.Text    = objResult.TotalWeight.ToString();
         StatusLabelPrice.Text     = objResult.TotalPrice.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("读取数据库出错,请检查网络;\r\n原因:" + ex.Message);
     }
 }
Example #3
0
        private void btnStat_Click(object sender, EventArgs e)
        {
            DeliveryResutl objResult = null;

            try
            {
                DeliveryDAC dac = new DeliveryDAC();
                objResult = dac.Statistic(customer.Text.Trim(), dtpStart.Value, dtpEnd.Value, specifications.Text.Trim(), goodname.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show("读取数据库出错,请检查网络;\r\n原因:" + ex.Message);
                return;
            }
            if (objResult != null)
            {
                MessageBox.Show("统计结果如下:\r\n总盘数:" + objResult.TotalDisc.ToString() + "\r\n总长度:" + objResult.TotalLength.ToString()
                                + "\r\n总重量:" + objResult.TotalWeight.ToString() + "\r\n总金额:" + objResult.TotalPrice.ToString());
            }
        }