Пример #1
0
        public void DoInsertCustomer(tmdlcustomer customer, List<tmdlcontact> lstContact)
        {
            try
            {
                dbInstance.BeginTransaction();
                baseDal.DoInsert(customer);

                ContactDal contactDal = new ContactDal(dbInstance);
                for (int i = 0; i < lstContact.Count; i++)
                {
                    lstContact[i].customerid = customer.customerid;
                    contactDal.DoInsert<tmdlcontact>(lstContact[i]);
                }

                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Пример #2
0
        private void DoSave()
        {
            try
            {
                baseForm.SetCursor();
                baseForm.ValidateData(this);

                tmdlcustomer customer = new tmdlcustomer();
                if (UpdateMode == Public_UpdateMode.Update)
                {
                    customer = baseForm.OriginalObject as tmdlcustomer;
                }
                baseForm.CreateSingleObject<tmdlcustomer>(customer, this, UpdateMode);

                List<tmdlcontact> lstContact = new List<tmdlcontact>();

                for (int i = 0; i < this.grdContact.Rows.Count; i++)
                {
                    tmdlcontact contact = new tmdlcontact();
                    contact.contactname = this.grdContact.Rows[i].Cells["contactname"].Value.ToString();
                    contact.customerid = this.grdContact.Rows[i].Cells["customerid"].Value.ToString();
                    contact.email = this.grdContact.Rows[i].Cells["email"].Value.ToString();
                    contact.faxno = this.grdContact.Rows[i].Cells["faxno"].Value.ToString();
                    contact.isdefault = this.grdContact.Rows[i].Cells["isdefault"].Value.ToString();
                    contact.mobileno = this.grdContact.Rows[i].Cells["mobileno"].Value.ToString();
                    contact.remark = this.grdContact.Rows[i].Cells["remark"].Value.ToString();
                    contact.telphone = this.grdContact.Rows[i].Cells["telphone"].Value.ToString();
                    contact.title = this.grdContact.Rows[i].Cells["title"].Value.ToString();
                    contact.sex = this.grdContact.Rows[i].Cells["sex"].Value.ToString();

                    baseForm.PrepareObject<tmdlcontact>(contact, Public_UpdateMode.Insert);

                    lstContact.Add(contact);
                }

                if (UpdateMode == Public_UpdateMode.Insert)
                {
                    InsertCustomer(customer, lstContact);
                }
                else
                {
                    UpdateCustomer(customer, lstContact);
                }

                if (UpdateMode == Public_UpdateMode.Insert)
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00001"));
                else if (UpdateMode == Public_UpdateMode.Update)
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00002"));

                this.Dispose();
            }
            catch (Exception ex)
            {
                MESMsgBox.ShowError(ExceptionParser.Parse(ex));
            }
            finally
            {
                baseForm.ResetCursor();
            }
        }
Пример #3
0
 public void DoInsertCustomer(ContextInfo contextInfo, tmdlcustomer customer,List<tmdlcontact> lstContact)
 {
     contextInfo.Action = MES_ActionType.Insert;
     CustomerBll bll = new CustomerBll(contextInfo);
     bll.CallAccessControl();
     bll.DoInsertCustomer(customer,lstContact);
     GC.Collect();
 }
Пример #4
0
        public void DoUpdateCustomer(tmdlcustomer customer, List<tmdlcontact> lstContact)
        {
            try
            {
                dbInstance.BeginTransaction();

                ContactDal contactDal = new ContactDal(dbInstance);
                List<MESParameterInfo> lstParams = new List<MESParameterInfo>() {
                            new MESParameterInfo(){ParamName="customerid",ParamValue=customer.customerid}
                        };

                List<tmdlcontact> lstOld = contactDal.GetSelectedObjects<tmdlcontact>(lstParams);

                for (int i = 0; i < lstContact.Count; i++)
                {
                    if (lstContact[i].customerid == null || lstContact[i].customerid == string.Empty)
                    {
                        //new
                        lstContact[i].customerid = customer.customerid;
                        contactDal.DoInsert<tmdlcontact>(lstContact[i]);
                    }
                    else
                    {
                        //do update
                        contactDal.DoUpdate<tmdlcontact>(lstContact[i]);
                    }
                }

                #region check Delete
                bool bDeleted = true;
                List<int> lstDeleteIdx = new List<int>();
                for (int i = 0; i < lstOld.Count; i++)
                {
                    bDeleted = true;
                    for (int j = 0; j < lstContact.Count; j++)
                    {
                        if (lstOld[i].contactname == lstContact[j].contactname)
                        {
                            bDeleted = false;
                        }
                    }

                    if (bDeleted)
                        lstDeleteIdx.Add(i);
                }

                for (int i = 0; i < lstDeleteIdx.Count; i++)
                {
                    contactDal.DoDelete<tmdlcontact>(lstOld[lstDeleteIdx[i]]);
                }
                #endregion

                baseDal.DoUpdate<tmdlcustomer>(customer);
                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Пример #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tmdlcustomer EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotmdlcustomer(tmdlcustomer tmdlcustomer)
 {
     base.AddObject("tmdlcustomer", tmdlcustomer);
 }
Пример #6
0
 /// <summary>
 /// Create a new tmdlcustomer object.
 /// </summary>
 /// <param name="customerid">Initial value of the customerid property.</param>
 /// <param name="customername">Initial value of the customername property.</param>
 /// <param name="lastmodifieduser">Initial value of the lastmodifieduser property.</param>
 /// <param name="lastmodifiedtime">Initial value of the lastmodifiedtime property.</param>
 public static tmdlcustomer Createtmdlcustomer(global::System.String customerid, global::System.String customername, global::System.String lastmodifieduser, global::System.DateTime lastmodifiedtime)
 {
     tmdlcustomer tmdlcustomer = new tmdlcustomer();
     tmdlcustomer.customerid = customerid;
     tmdlcustomer.customername = customername;
     tmdlcustomer.lastmodifieduser = lastmodifieduser;
     tmdlcustomer.lastmodifiedtime = lastmodifiedtime;
     return tmdlcustomer;
 }
Пример #7
0
 private void UpdateCustomer(tmdlcustomer _customer, List<tmdlcontact> lstContact)
 {
     wsMDL.IwsMDLClient client = new wsMDL.IwsMDLClient();
     try
     {
         client.DoUpdateCustomer(baseForm.CurrentContextInfo, _customer, lstContact.ToArray());
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         baseForm.CloseWCF(client);
     }
 }