protected void btnSave_Click(object sender, EventArgs e)
    {
        string replaceId = "";

        if (btnSave.Text == "Save")
        {
            string imageName = "";
            //txtId.Text = "1003";
            string fileName = Path.GetFileName(fileUpload.PostedFile.FileName);
            string imgId    = txtId.Text + ".jpg";

            if (fileName != "" && fileName != null)
            {
                replaceId = fileName.Replace(fileName, imgId);
                fileUpload.SaveAs(Server.MapPath("HawkerImage/" + replaceId));
            }

            try
            {
                imageName                  = "~/HawkerImage/" + replaceId;
                contractDeedObj            = new BLLContractDeed();
                contractDeedObj.HawkerId   = txtId.Text.ToString();
                contractDeedObj.HawkerName = txtName.Text;
                contractDeedObj.IssueDate  = Convert.ToDateTime(txtIssuDate.Text);
                // DateTime asd = Convert.ToDateTime(txtExpDate.Text);
                contractDeedObj.DeedType   = ddlDeedType.SelectedItem.Text;
                contractDeedObj.ExpDate    = Convert.ToDateTime(txtExpDate.Text);
                contractDeedObj.Bank       = txtBank.Text;
                contractDeedObj.DepositeTk = Convert.ToInt32(txtDeposit.Text);
                contractDeedObj.ImgName    = imageName.ToString();
                contractDeedObj.auditUser  = Session["UserName"].ToString();
                contractDeedObj.createDate = DateTime.Now;
            }
            catch (Exception frmEx)
            {
                msgError.Text = "Enter numeric figure in deposit field" + frmEx.Message;
            }
            contractDeedObj.Save(contractDeedObj);
        }

        else if (btnSave.Text == "Update")
        {
            contractDeedObj = new BLLContractDeed();
            string   hawkerName = txtName.Text;
            string   HawkerId   = txtId.Text;
            DateTime issueDate  = Convert.ToDateTime(txtIssuDate.Text);
            string   DeedType   = ddlDeedType.SelectedItem.Text;
            DateTime expDate    = Convert.ToDateTime(txtExpDate.Text);
            string   bank       = txtBank.Text;
            int      deposit    = Convert.ToInt32(txtDeposit.Text);
            string   auditUser  = Session["UserName"].ToString();
            DateTime createDate = DateTime.Now;
            contractDeedObj.Update(HawkerId, hawkerName, issueDate, DeedType, expDate, bank, deposit, auditUser, createDate);
        }
        // DisplayHawker();
        Clear();
    }
示例#2
0
    public void Save(BLLContractDeed contractDeedObj)
    {
        SqlCommand cmd = new SqlCommand("spAgentDeed", con);

        cmd.CommandType = CommandType.StoredProcedure;
        con.Open();

        cmd.Parameters.Add("@Flag", SqlDbType.TinyInt).Value       = 1;
        cmd.Parameters.Add("@HawkerId", SqlDbType.VarChar).Value   = contractDeedObj.HawkerId;
        cmd.Parameters.Add("@HawkerName", SqlDbType.VarChar).Value = contractDeedObj.HawkerName;
        cmd.Parameters.Add("@IssueDate", SqlDbType.DateTime).Value = contractDeedObj.IssueDate;
        cmd.Parameters.Add("@deedType", SqlDbType.VarChar).Value   = contractDeedObj.DeedType;
        cmd.Parameters.Add("@ExpDate", SqlDbType.DateTime).Value   = contractDeedObj.ExpDate;
        cmd.Parameters.Add("@bank", SqlDbType.VarChar).Value       = contractDeedObj.Bank;
        cmd.Parameters.Add("@DepositTk", SqlDbType.Int).Value      = contractDeedObj.DepositeTk;
        cmd.Parameters.Add("@ImgName", SqlDbType.VarChar).Value    = contractDeedObj.ImgName;
        cmd.Parameters.Add("@auditUser", SqlDbType.VarChar).Value  = contractDeedObj.auditUser;
        cmd.Parameters.Add("@createDate", SqlDbType.Date).Value    = contractDeedObj.createDate;
        //cmd.Parameters.AddWithValue("@ImgName", contractDeedObj.ImgName);
        cmd.ExecuteNonQuery();

        con.Close();
    }
 public void Save(BLLContractDeed contractDeedObj)
 {
     dalDeedObj.Save(contractDeedObj);
 }