Example #1
0
 private void Clear_textBoxes()
 {
     FirstName.Clear();
     LastName.Clear();
     ProductName.Clear();
     wholesalecost.Clear();
     SaleCost.Clear();
 }
Example #2
0
        public static void BatchSaleCost(DataTable dt, Oper oper)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    foreach (DataRow dr in dt.Rows)
                    {
                        SaleCost sc = new SaleCost(dr);
                        //newOper.cndCreateDate = dtSysTime;
                        string strCount = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select count(*) from tbSaleCost where cnnCustID = " + sc.cnnCustID + " and cnvcYear='" + sc.cnvcYear + "'").ToString();
                        if (Convert.ToInt32(strCount) > 0)
                        {
                            throw new Exception(sc.cnnCustID + "的" + sc.cnvcYear + "年成本管理已存在");
                        }

                        EntityMapping.Create(sc, trans);

                        BusiLog busiLog = new BusiLog();
                        busiLog.cndOperDate     = dtSysTime;
                        busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                        busiLog.cnvcComments    = sc.cnvcCustName;
                        busiLog.cnvcFuncCode    = " 批量添加销售成本";
                        busiLog.cnvcOperID      = oper.cnvcOperID;
                        busiLog.cnvcIPAddress   = "";
                        EntityMapping.Create(busiLog, trans);
                    }
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
        private void btnOK_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            try
            {
                if (txtCustID.Text.Trim() == "" || this.ddlYear.SelectedValue == "")
                {
                    Popup("请选择客户和年份!");
                    return;
                }
                string    strSql = "select * from tbSaleCost where cnnCustID = " + txtCustID.Text.Trim() + " and cnvcYear='" + this.ddlYear.SelectedValue + "'";
                DataTable dt     = Helper.Query(strSql);
                if (dt.Rows.Count > 0)
                {
                    Popup("本销售成本存在冲突");
                    return;
                }

                if (this.JudgeIsNull(txtCustName.Text.Trim(), "客户名称"))
                {
                    return;
                }
                if (this.JudgeIsNull(txtBudgetCost.Text.Trim(), "预算销售成本") || !this.JudgeIsNum(txtBudgetCost.Text.Trim(), "预算销售成本"))
                {
                    return;
                }
                if (this.JudgeIsNull(txtRealSaleCost.Text.Trim(), "实际销售成本合计") || !this.JudgeIsNum(txtRealSaleCost.Text.Trim(), "实际销售成本合计"))
                {
                    return;
                }

                SaleCost cost = new SaleCost();
                cost.cnnCustID       = decimal.Parse(txtCustID.Text.Trim());
                cost.cnvcCustName    = txtCustName.Text.Trim();
                cost.cnvcYear        = ddlYear.SelectedValue;
                cost.cnnBudgetCost   = decimal.Parse(txtBudgetCost.Text.Trim());
                cost.cnnRealSaleCost = decimal.Parse(txtRealSaleCost.Text.Trim());

                SalesManageFacade.AddSaleCost(cost, oper);
                Popup("销售成本添加成功");
                this.txtCustID.Text       = "";
                this.txtCustName.Text     = "";
                this.txtBudgetCost.Text   = "";
                this.txtRealSaleCost.Text = "";
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
Example #4
0
        public static void UpdateSaleCost(SaleCost cost, Oper oper)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);
                    //newOper.cndCreateDate = dtSysTime;
                    EntityMapping.Update(cost, trans);

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = cost.cnvcCustName;
                    busiLog.cnvcFuncCode    = " 修改销售成本";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
Example #5
0
        private void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                SaleCost cost    = new SaleCost();
                decimal  costsum = 0;
                //1月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim(), "1月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim(), "1月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed1 = decimal.Parse(((TextBox)e.Item.Cells[6].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed1;
                }
                //2月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[7].Controls[0]).Text.Trim(), "2月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[7].Controls[0]).Text.Trim(), "2月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed2 = decimal.Parse(((TextBox)e.Item.Cells[7].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed2;
                }
                //3月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[8].Controls[0]).Text.Trim(), "3月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[8].Controls[0]).Text.Trim(), "3月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed3 = decimal.Parse(((TextBox)e.Item.Cells[8].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed3;
                }
                //4月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[9].Controls[0]).Text.Trim(), "4月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[9].Controls[0]).Text.Trim(), "4月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed4 = decimal.Parse(((TextBox)e.Item.Cells[9].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed4;
                }
                //5月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim(), "5月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim(), "5月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed5 = decimal.Parse(((TextBox)e.Item.Cells[10].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed5;
                }
                //6月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim(), "6月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim(), "6月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed6 = decimal.Parse(((TextBox)e.Item.Cells[11].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed6;
                }
                //7月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[12].Controls[0]).Text.Trim(), "7月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[12].Controls[0]).Text.Trim(), "7月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed7 = decimal.Parse(((TextBox)e.Item.Cells[12].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed7;
                }
                //8月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[13].Controls[0]).Text.Trim(), "8月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[13].Controls[0]).Text.Trim(), "8月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed8 = decimal.Parse(((TextBox)e.Item.Cells[13].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed8;
                }
                //9月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[14].Controls[0]).Text.Trim(), "9月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[14].Controls[0]).Text.Trim(), "9月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed9 = decimal.Parse(((TextBox)e.Item.Cells[14].Controls[0]).Text.Trim());
                    costsum      += cost.cnnUsed9;
                }
                //10月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[15].Controls[0]).Text.Trim(), "10月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[15].Controls[0]).Text.Trim(), "10月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed10 = decimal.Parse(((TextBox)e.Item.Cells[15].Controls[0]).Text.Trim());
                    costsum       += cost.cnnUsed10;
                }
                //11月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[16].Controls[0]).Text.Trim(), "11月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[16].Controls[0]).Text.Trim(), "11月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed11 = decimal.Parse(((TextBox)e.Item.Cells[16].Controls[0]).Text.Trim());
                    costsum       += cost.cnnUsed11;
                }
                //12月
                if (this.JudgeIsNull(((TextBox)e.Item.Cells[17].Controls[0]).Text.Trim(), "12月使用") || !this.JudgeIsNum(((TextBox)e.Item.Cells[17].Controls[0]).Text.Trim(), "12月使用"))
                {
                    return;
                }
                else
                {
                    cost.cnnUsed12 = decimal.Parse(((TextBox)e.Item.Cells[17].Controls[0]).Text.Trim());
                    costsum       += cost.cnnUsed12;
                }

                cost.cnnCustID       = decimal.Parse(e.Item.Cells[0].Text.Trim());
                cost.cnvcCustName    = e.Item.Cells[1].Text.Trim();
                cost.cnvcYear        = e.Item.Cells[2].Text.Trim();
                cost.cnnBudgetCost   = decimal.Parse(e.Item.Cells[3].Text.Trim());
                cost.cnnRealSaleCost = decimal.Parse(e.Item.Cells[4].Text.Trim());
                cost.cnnCostUsed     = costsum;

                SalesManageFacade.UpdateSaleCost(cost, oper);
                Popup("销售成本修改成功");

                string    strsql = "select * from tbSaleCost where cnnCustID=" + cost.cnnCustID + " and cnvcYear='" + cost.cnvcYear + "' order by cnnCustID,cnvcYear";
                DataTable dtout  = Helper.Query(strsql);
                Session.Remove("QUERY");
                Session["QUERY"]             = dtout;
                this.DataGrid1.EditItemIndex = -1;
                this.DataGrid1.DataSource    = dtout;
                this.DataGrid1.DataBind();
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }