Esempio n. 1
0
 public bool SaveUpdate(mdlTenderDocument objmdlTenderDocument, string SaveUpdate)
 {
     return objdalTenderDocument.SaveUpdate(objmdlTenderDocument, SaveUpdate);
 }
Esempio n. 2
0
        public bool SaveUpdate(mdlTenderDocument objmdlTenderDocument, string SaveUpdate)
        {
            bool save = false;

            try
            {
                if (conn.State == ConnectionState.Open)
                    conn.Close();
                conn.Open();
                SqlCommand cmd = new SqlCommand("stp_ERP_TenderDocument_CRUD", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@DocId", SqlDbType.VarChar, 6).Value = objmdlTenderDocument.DocId;
                cmd.Parameters.Add("@DocName", SqlDbType.VarChar, 30).Value = objmdlTenderDocument.DocName;
                cmd.Parameters.Add("@Description", SqlDbType.VarChar, 100).Value = objmdlTenderDocument.Description;
                cmd.Parameters.Add("@TenderType", SqlDbType.VarChar, 30).Value = objmdlTenderDocument.TenderType;
                cmd.Parameters.Add("@AddUser", SqlDbType.VarChar, 10).Value = objmdlTenderDocument.AddUser;

                if (SaveUpdate == "Save")
                {
                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Save";
                }
                if (SaveUpdate == "Update")
                {
                    cmd.Parameters.Add("@Operation", SqlDbType.VarChar, 20).Value = "Update";
                }
                cmd.ExecuteNonQuery();
                conn.Close();
                save = true;

                if (save == true)
                {
                    if (objmdlTenderDocument.Attachment != "" && SaveUpdate == "Save")
                    {
                        objSaveDownloadFile.UpdateData("DocId", objmdlTenderDocument.DocId, "Attachment", "M_TenderDocument", objmdlTenderDocument.Attachment, "", "TenderFile");
                    }
                    if (objmdlTenderDocument.Attachment != "" && SaveUpdate == "Update")
                    {
                        if (conn.State == ConnectionState.Open) { conn.Close(); }
                        conn.Open();
                        SqlCommand cmdCheck = new SqlCommand("Select Attachment FROM M_TenderDocument WHERE DocId = " + objmdlTenderDocument.DocId, conn);
                        cmdCheck.CommandType = CommandType.Text;
                        if (objmdlTenderDocument.Attachment != cmdCheck.ExecuteScalar().ToString())
                        {
                            objSaveDownloadFile.UpdateData("DocId", objmdlTenderDocument.DocId, "Attachment", "M_TenderDocument", objmdlTenderDocument.Attachment, "", "TenderFile");
                        }
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Babar Medicine Company", MessageBoxButtons.OK, MessageBoxIcon.Error);
                save = false;
            }
            return save;
        }