public bool updateTran(VAN_OA.Model.EFrom.Tb_ProjectInv model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Tb_ProjectInvs> proInvs, string IDS)
        {
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;


                Tb_ProjectInvsService prosInvsSer = new Tb_ProjectInvsService();
                try
                {
                    objCommand.Parameters.Clear();
                    Update(model, objCommand);
                    tb_EFormService eformSer = new tb_EFormService();
                    eformSer.Update(eform, objCommand);
                    tb_EFormsService eformsSer = new tb_EFormsService();
                    eformsSer.Add(forms, objCommand);


                    for (int i = 0; i < proInvs.Count; i++)
                    {
                        proInvs[i].PId = model.Id;

                        if (proInvs[i].IfUpdate == true && proInvs[i].Id != 0)
                        {
                            prosInvsSer.Update(proInvs[i], objCommand);
                        }
                        else if (proInvs[i].Id == 0)
                        {
                            prosInvsSer.Add(proInvs[i], objCommand);
                        }
                    }
                    if (IDS != "")
                    {
                        IDS = IDS.Substring(0, IDS.Length - 1);
                        prosInvsSer.DeleteByIds(IDS, objCommand);
                    }

                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(false);
                }
            }

            return(true);
        }
        public int addTran(VAN_OA.Model.EFrom.Tb_ProjectInv model, VAN_OA.Model.EFrom.tb_EForm eform, List <Tb_ProjectInvs> proInvs)
        {
            int id     = 0;
            int MainId = 0;

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                Tb_ProjectInvsService proInvsSer = new Tb_ProjectInvsService();
                try
                {
                    tb_EFormService eformSer = new tb_EFormService();
                    objCommand.Parameters.Clear();
                    string proNo = eformSer.GetAllE_No("Tb_ProjectInv", objCommand);
                    model.ProNo = proNo;
                    eform.E_No  = proNo;

                    id     = Add(model, objCommand);
                    MainId = id;

                    eform.allE_id = id;
                    eformSer.Add(eform, objCommand);
                    for (int i = 0; i < proInvs.Count; i++)
                    {
                        proInvs[i].PId = id;
                        proInvsSer.Add(proInvs[i], objCommand);
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }