Beispiel #1
0
        /// <summary>
        /// reset production form
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool ResetPrice(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modProductionForm mod = GetItem(formid, out emsg);
                sql = string.Format("update production_form set price_status={0} where form_id='{2}'", 0, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// audit production form
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Audit(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modProductionForm mod = GetItem(formid, out emsg);
                if (mod.Status == 1)
                {
                    emsg = "这张单据已经审核,您无须再审";
                    return(false);
                }
                BindingCollection <modProductionFormWare> listware = GetProductionFormWare(formid, out emsg);
                if (listware != null && listware.Count > 0)
                {
                    foreach (modProductionFormWare modware in listware)
                    {
                        sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", modware.WarehouseId, modware.ProductId, modware.Size, formid, mod.FormType, mod.No, mod.FormDate, 0, modware.Qty, 0, modware.Remark, updateuser);
                        SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                        cmd.ExecuteNonQuery();
                    }
                }
                BindingCollection <modProductionFormMaterial> listmaterial = GetProductionFormMaterial(formid, out emsg);
                if (listmaterial != null && listmaterial.Count > 0)
                {
                    foreach (modProductionFormMaterial modmaterial in listmaterial)
                    {
                        sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", modmaterial.WarehouseId, modmaterial.ProductId, modmaterial.Size, formid, mod.FormType, mod.No, mod.FormDate, 0, 0, modmaterial.Qty, modmaterial.Remark, updateuser);
                        SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                        cmd.ExecuteNonQuery();
                    }
                }
                sql = string.Format("update production_form set status={0},audit_man='{1}',audit_time=getdate() where form_id='{2}'", 1, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
 private void toolPrice_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modProductionForm mod = (modProductionForm)DBGrid.CurrentRow.DataBoundItem;
         if (mod.AccSeq > 0)
         {
             MessageBox.Show("该单据已做凭证,不可修改单价!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
             //return;
         }
         EditProductionForm frm = new EditProductionForm();
         frm.EditItem(mod.FormId, true);
         if (frm.ShowDialog() == DialogResult.OK)
         {
             DBGrid.CurrentRow.Cells["PriceStatus"].Value = 1;
             DBGrid.CurrentRow.DefaultCellStyle.ForeColor = Color.DarkGray;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Beispiel #4
0
 private void toolEdit_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         modProductionForm  mod = (modProductionForm)DBGrid.CurrentRow.DataBoundItem;
         EditProductionForm frm = new EditProductionForm();
         frm.EditItem(mod.FormId, false);
         if (frm.ShowDialog() == DialogResult.OK)
         {
             LoadData();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Beispiel #5
0
        /// <summary>
        /// get form for credence list
        /// <summary>
        /// <param name=fromdate>fromdate</param>
        /// <param name=todate>todate</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all productionform</returns>
        public BindingCollection <modProductionForm> GetWaitCredenceList(string fromdate, string todate, out string emsg)
        {
            try
            {
                BindingCollection <modProductionForm> modellist = new BindingCollection <modProductionForm>();
                //Execute a query to read the categories
                string formdatewhere = string.Empty;
                if (!string.IsNullOrEmpty(fromdate))
                {
                    formdatewhere = "and a.form_date >= '" + Convert.ToDateTime(fromdate) + "' ";
                }
                if (!string.IsNullOrEmpty(todate))
                {
                    formdatewhere += "and a.form_date <= '" + Convert.ToDateTime(todate) + "' ";
                }

                string sql = "select form_id,status,price_status,form_date,require_date,form_type,dept_id,no,process_mny,detail_sum,kill_mny,other_mny,other_reason,ship_man,remark,currency,exchange_rate,update_user,update_time,audit_man,audit_time,acc_name,acc_seq "
                             + "from production_form a where a.status=1 and a.price_status=1 and (a.acc_name is null or a.acc_name='') and a.acc_seq=0 " + formdatewhere + "order by form_id";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modProductionForm model = new modProductionForm();
                        model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                        model.Status       = dalUtility.ConvertToInt(rdr["status"]);
                        model.PriceStatus  = dalUtility.ConvertToInt(rdr["price_status"]);
                        model.FormDate     = dalUtility.ConvertToDateTime(rdr["form_date"]);
                        model.FormType     = dalUtility.ConvertToString(rdr["form_type"]);
                        model.DeptId       = dalUtility.ConvertToString(rdr["dept_id"]);
                        model.No           = dalUtility.ConvertToString(rdr["no"]);
                        model.ProcessMny   = dalUtility.ConvertToDecimal(rdr["process_mny"]);
                        model.MaterialMny  = GetMaterialMny(model.FormId);
                        model.WareMny      = GetWareMny(model.FormId);
                        model.KillMny      = dalUtility.ConvertToDecimal(rdr["kill_mny"]);
                        model.OtherMny     = dalUtility.ConvertToDecimal(rdr["other_mny"]);
                        model.OtherReason  = dalUtility.ConvertToString(rdr["other_reason"]);
                        model.ShipMan      = dalUtility.ConvertToString(rdr["ship_man"]);
                        model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                        model.Currency     = dalUtility.ConvertToString(rdr["currency"]);
                        model.ExchangeRate = dalUtility.ConvertToDecimal(rdr["exchange_rate"]);
                        model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                        model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                        model.AuditMan     = dalUtility.ConvertToString(rdr["audit_man"]);
                        model.AuditTime    = dalUtility.ConvertToDateTime(rdr["audit_time"]);
                        model.AccName      = dalUtility.ConvertToString(rdr["acc_name"]);
                        model.AccSeq       = dalUtility.ConvertToInt(rdr["acc_seq"]);
                        modellist.Add(model);
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }
Beispiel #6
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=formid>formid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of productionform</returns>
 public modProductionForm GetItem(string formid, out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = string.Format("select form_id,status,price_status,form_date,require_date,form_type,dept_id,no,process_mny,detail_sum,kill_mny,other_mny,other_reason,ship_man,remark,currency,exchange_rate,update_user,update_time,audit_man,audit_time,acc_name,acc_seq from production_form where form_id='{0}' order by form_id", formid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modProductionForm model = new modProductionForm();
                 model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                 model.Status       = dalUtility.ConvertToInt(rdr["status"]);
                 model.PriceStatus  = dalUtility.ConvertToInt(rdr["price_status"]);
                 model.FormDate     = dalUtility.ConvertToDateTime(rdr["form_date"]);
                 model.RequireDate  = dalUtility.ConvertToDateTime(rdr["require_date"]);
                 model.FormType     = dalUtility.ConvertToString(rdr["form_type"]);
                 model.DeptId       = dalUtility.ConvertToString(rdr["dept_id"]);
                 model.No           = dalUtility.ConvertToString(rdr["no"]);
                 model.ProcessMny   = dalUtility.ConvertToDecimal(rdr["process_mny"]);
                 model.MaterialMny  = GetMaterialMny(model.FormId);
                 model.WareMny      = GetWareMny(model.FormId);
                 model.KillMny      = dalUtility.ConvertToDecimal(rdr["kill_mny"]);
                 model.OtherMny     = dalUtility.ConvertToDecimal(rdr["other_mny"]);
                 model.OtherReason  = dalUtility.ConvertToString(rdr["other_reason"]);
                 model.ShipMan      = dalUtility.ConvertToString(rdr["ship_man"]);
                 model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                 model.Currency     = dalUtility.ConvertToString(rdr["currency"]);
                 model.ExchangeRate = dalUtility.ConvertToDecimal(rdr["exchange_rate"]);
                 model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 model.AuditMan     = dalUtility.ConvertToString(rdr["audit_man"]);
                 model.AuditTime    = dalUtility.ConvertToDateTime(rdr["audit_time"]);
                 model.AccName      = dalUtility.ConvertToString(rdr["acc_name"]);
                 model.AccSeq       = dalUtility.ConvertToInt(rdr["acc_seq"]);
                 emsg = null;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Beispiel #7
0
        /// <summary>
        /// reset production form
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Reset(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modProductionForm mod = GetItem(formid, out emsg);
                if (mod.Status == 0)
                {
                    emsg = "这张单据尚未审核,您无须重置";
                    return(false);
                }
                sql = string.Format("delete warehouse_product_inout where form_id='{0}' and form_type='{1}'", formid, mod.FormType);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                sql = string.Format("update production_form set status={0},audit_man='{1}',audit_time=null where form_id='{2}'", 0, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
Beispiel #8
0
        private void toolExport_Click(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }
            IList <modExcelRangeData> list = new List <modExcelRangeData>();
            modProductionForm         mod  = (modProductionForm)DBGrid.CurrentRow.DataBoundItem;

            list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_NAME"), "B1", "J1"));
            list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_ADDR"), "B2", "J2"));
            list.Add(new modExcelRangeData("电话:" + clsLxms.GetParameterValue("COMPANY_TEL") + "      传真:" + clsLxms.GetParameterValue("COMPANY_FAX"), "B3", "J3"));

            list.Add(new modExcelRangeData(mod.No, "J4", "J4"));
            list.Add(new modExcelRangeData(mod.DeptId, "D5", "H5"));
            list.Add(new modExcelRangeData(mod.FormDate.ToString("yyyy年MM月dd日"), "J5", "J5"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.MaterialMny), "E15", "I15"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.OtherMny), "E16", "I16"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.KillMny), "E17", "I17"));
            list.Add(new modExcelRangeData(mod.OtherReason, "J16", "J16"));
            list.Add(new modExcelRangeData(mod.Remark, "D19", "J19"));
            list.Add(new modExcelRangeData(mod.AuditMan, "G21", "H21"));
            list.Add(new modExcelRangeData(mod.ShipMan, "J21", "J21"));
            BindingCollection <modProductionFormWare> listdetail = _dal.GetProductionFormWare(mod.FormId, out Util.emsg);

            for (int i = 0; i < listdetail.Count; i++)
            {
                modProductionFormWare modd = listdetail[i];
                string col = (7 + i).ToString().Trim();
                list.Add(new modExcelRangeData((i + 1).ToString(), "B" + col, "B" + col));
                list.Add(new modExcelRangeData(modd.ProductName, "C" + col, "D" + col));
                list.Add(new modExcelRangeData(modd.Specify, "E" + col, "F" + col));
                list.Add(new modExcelRangeData(modd.Qty.ToString(), "G" + col, "G" + col));
                list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ProcessPrice), "H" + col, "H" + col));
                list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.ProcessPrice), "I" + col, "I" + col));
                list.Add(new modExcelRangeData(modd.Remark, "J" + col, "J" + col));
            }
            clsExport.ExportByTemplate(list, "外发加工单", 1, 21, 10, 1);
        }
Beispiel #9
0
 private void toolDel_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (DBGrid.CurrentRow == null)
         {
             return;
         }
         if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to delete it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         modProductionForm mod = _dal.GetItem(DBGrid.CurrentRow.Cells[0].Value.ToString(), out Util.emsg);
         if (mod.Status == 1)
         {
             MessageBox.Show("该单据已审核,您不能删除!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         bool ret = _dal.Save("DEL", mod, null, null, out Util.emsg);
         if (ret)
         {
             LoadData();
         }
         else
         {
             MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Beispiel #10
0
        /// <summary>
        /// insert a production form
        /// <summary>
        /// <param name=mod>model object of production form</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Save(string oprtype, modProductionForm mod, BindingCollection <modProductionFormWare> listware, BindingCollection <modProductionFormMaterial> listmaterial, out string emsg)
        {
            using (TransactionScope transaction = new TransactionScope())//使用事务
            {
                try
                {
                    string sql    = string.Empty;
                    string formid = mod.FormId;
                    int?   seq    = 0;
                    switch (oprtype)
                    {
                    case "ADD":
                    case "NEW":
                        if (Exists(formid, out emsg))
                        {
                            formid = GetNewFormId(mod.FormDate);
                        }
                        sql = string.Format("insert into production_form(form_id,status,price_status,form_date,form_type,dept_id,no,currency,exchange_rate,detail_sum,kill_mny,other_mny,other_reason,remark,ship_man,update_user,update_time,require_date,process_mny)values('{0}',{1},{2},'{3}','{4}','{5}','{6}','{7}',{8},{9},{10},{11},'{12}','{13}','{14}','{15}',getdate(),'{16}',{17})", formid, 0, 0, mod.FormDate, mod.FormType, mod.DeptId, mod.No, mod.Currency, mod.ExchangeRate, mod.MaterialMny, mod.KillMny, mod.OtherMny, mod.OtherReason, mod.Remark, mod.ShipMan, mod.UpdateUser, mod.RequireDate, mod.ProcessMny);
                        SqlHelper.ExecuteNonQuery(sql);
                        seq = 0;
                        foreach (modProductionFormWare modware in listware)
                        {
                            seq++;
                            sql = string.Format("insert into production_form_ware(form_id,seq,product_id,product_name,specify,size,qty,process_price,cost_price,warehouse_id,remark)values('{0}',{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", formid, seq, modware.ProductId, modware.ProductName, modware.Specify, modware.Size, modware.Qty, modware.ProcessPrice, modware.CostPrice, modware.WarehouseId, modware.Remark);
                            SqlHelper.ExecuteNonQuery(sql);
                        }
                        seq = 0;
                        foreach (modProductionFormMaterial modmaterial in listmaterial)
                        {
                            seq++;
                            sql = string.Format("insert into production_form_material(form_id,seq,product_id,product_name,specify,size,qty,cost_price,warehouse_id,remark)values('{0}',{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", formid, seq, modmaterial.ProductId, modmaterial.ProductName, modmaterial.Specify, modmaterial.Size, modmaterial.Qty, modmaterial.CostPrice, modmaterial.WarehouseId, modmaterial.Remark);
                            SqlHelper.ExecuteNonQuery(sql);
                        }
                        break;

                    case "EDIT":
                    case "UPDATE":
                    case "MODIFY":
                        sql = string.Format("update production_form set status={0},price_status={1},form_date='{2}',form_type='{3}',dept_id='{4}',no='{5}',currency='{6}',exchange_rate={7},detail_sum={8},kill_mny={9},other_mny={10},other_reason='{11}',remark='{12}',ship_man='{13}',require_date='{14}',process_mny={15} where form_id='{16}'", 0, 0, mod.FormDate, mod.FormType, mod.DeptId, mod.No, mod.Currency, mod.ExchangeRate, mod.MaterialMny, mod.KillMny, mod.OtherMny, mod.OtherReason, mod.Remark, mod.ShipMan, mod.RequireDate, mod.ProcessMny, formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        sql = string.Format("delete production_form_ware where form_id='{0}'", formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        sql = string.Format("delete production_form_material where form_id='{0}'", formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        seq = 0;
                        foreach (modProductionFormWare modware in listware)
                        {
                            seq++;
                            sql = string.Format("insert into production_form_ware(form_id,seq,product_id,product_name,specify,size,qty,process_price,cost_price,warehouse_id,remark)values('{0}',{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", formid, seq, modware.ProductId, modware.ProductName, modware.Specify, modware.Size, modware.Qty, modware.ProcessPrice, modware.CostPrice, modware.WarehouseId, modware.Remark);
                            SqlHelper.ExecuteNonQuery(sql);
                        }
                        seq = 0;
                        foreach (modProductionFormMaterial modmaterial in listmaterial)
                        {
                            seq++;
                            sql = string.Format("insert into production_form_material(form_id,seq,product_id,product_name,specify,size,qty,cost_price,warehouse_id,remark)values('{0}',{1},'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", formid, seq, modmaterial.ProductId, modmaterial.ProductName, modmaterial.Specify, modmaterial.Size, modmaterial.Qty, modmaterial.CostPrice, modmaterial.WarehouseId, modmaterial.Remark);
                            SqlHelper.ExecuteNonQuery(sql);
                        }
                        break;

                    case "DEL":
                    case "DELETE":
                        sql = string.Format("delete production_form_ware where form_id='{0}'", formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        sql = string.Format("delete production_form_material where form_id='{0}'", formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        sql = string.Format("delete production_form where form_id='{0}'", formid);
                        SqlHelper.ExecuteNonQuery(sql);
                        break;
                    }

                    transaction.Complete();//就这句就可以了。
                    emsg = formid;
                    return(true);
                }
                catch (Exception ex)
                {
                    emsg = dalUtility.ErrorMessage(ex.Message);
                    return(false);
                }
            }
        }
        private void toolReset_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (DBGrid.RowCount == 0)
                {
                    return;
                }
                if (DBGrid.SelectedRows.Count == 0 && DBGrid.CurrentRow == null)
                {
                    return;
                }
                if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to reset it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                if (DBGrid.SelectedRows.Count == 0)
                {
                    modProductionForm mod = (modProductionForm)DBGrid.CurrentRow.DataBoundItem;
                    if (mod.PriceStatus == 1 && _dal.ResetPrice(mod.FormId, Util.UserId, out Util.emsg))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Reset Success!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DBGrid.CurrentRow.Cells["PriceStatus"].Value = 0;
                        DBGrid.CurrentRow.DefaultCellStyle.ForeColor = Color.Black;
                        DBGrid.CurrentRow.Selected = false;
                    }
                    else
                    {
                        MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.AccSeq.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                else
                {
                    for (int i = DBGrid.SelectedRows.Count - 1; i >= 0; i--)
                    {
                        modProductionForm mod = (modProductionForm)DBGrid.SelectedRows[i].DataBoundItem;
                        if (mod.PriceStatus == 1 && _dal.ResetPrice(mod.FormId, Util.UserId, out Util.emsg))
                        {
                            DBGrid.SelectedRows[i].Cells["PriceStatus"].Value = 0;
                            DBGrid.SelectedRows[i].DefaultCellStyle.ForeColor = Color.Black;
                            DBGrid.SelectedRows[i].Selected = false;
                        }
                        else
                        {
                            MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.AccSeq.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #12
0
        private void toolReset_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (DBGrid.RowCount == 0)
                {
                    return;
                }
                if (DBGrid.SelectedRows.Count == 0 && DBGrid.CurrentRow == null)
                {
                    return;
                }
                if (MessageBox.Show(clsTranslate.TranslateString("Do you really want to reset it?"), clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                if (DBGrid.SelectedRows.Count == 0)
                {
                    modProductionForm mod = _dal.GetItem(DBGrid.CurrentRow.Cells[0].Value.ToString(), out Util.emsg);
                    if (mod.AccSeq > 0)
                    {
                        MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (_dal.Reset(mod.FormId, Util.UserId, out Util.emsg))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Reset Success!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadData();
                    }
                    else
                    {
                        MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.FormId.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                else
                {
                    for (int i = DBGrid.SelectedRows.Count - 1; i >= 0; i--)
                    {
                        modProductionForm mod = _dal.GetItem(DBGrid.SelectedRows[i].Cells[0].Value.ToString(), out Util.emsg);
                        if (mod.AccSeq > 0)
                        {
                            MessageBox.Show("该单据已做凭证,不可重置!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (_dal.Reset(mod.FormId, Util.UserId, out Util.emsg))
                        {
                            //
                        }
                        else
                        {
                            MessageBox.Show(clsTranslate.TranslateString(Util.emsg), mod.FormId.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                    LoadData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }