示例#1
0
        private bool SaveDetail()
        {
            bool    blnResult = false;
            cDeduct oDeduct   = new cDeduct();

            try
            {
                string strUserName = Session["username"].ToString();
                StoreDetail();
                foreach (DataRow dr in this.dtDeductDetail.Rows)
                {
                    if (Helper.CStr(dr["recv_item_code"]).Trim().Length > 0)
                    {
                        var detail = new Deduct_detail
                        {
                            deduct_doc_no           = txtdeduct_doc.Text,
                            deduct_detail_id        = Helper.CLong(dr["deduct_detail_id"]),
                            recv_item_code          = Helper.CStr(dr["recv_item_code"]),
                            recv_item_rate          = Helper.CDec(dr["recv_item_rate"]),
                            deduct_item_amount      = Helper.CDec(dr["deduct_item_amount"]),
                            deduct_item_is_director = Helper.CBool(dr["deduct_item_is_director"]),
                            deduct_item_remark      = Helper.CStr(dr["deduct_item_remark"]),
                            c_created_by            = strUserName,
                            c_updated_by            = strUserName
                        };
                        if (Helper.CStr(dr["row_status"]) == "N")
                        {
                            oDeduct.SP_DEDUCT_DETAIL_INS(detail);
                        }
                        else if (Helper.CStr(dr["row_status"]) == "O")
                        {
                            oDeduct.SP_DEDUCT_DETAIL_UPD(detail);
                        }
                        else if (Helper.CStr(dr["row_status"]) == "D")
                        {
                            oDeduct.SP_DEDUCT_DETAIL_DEL(detail.deduct_detail_id);
                        }
                    }
                }
                this.dtDeductDetail = null;
                blnResult           = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oDeduct.Dispose();
            }
            return(blnResult);
        }
示例#2
0
        private bool saveData()
        {
            bool   blnResult    = false;
            string strUpdatedBy = string.Empty;

            strUpdatedBy = Session["username"].ToString();
            CheckBox      chkSelect;
            Label         lblrecv_item_code        = null;
            Label         lblrecv_item_name        = null;
            AwNumeric     txtrecv_item_rate        = null;
            CheckBox      chkRecv_item_is_director = null;
            var           oDeduct       = new cDeduct();
            Deduct_detail deduct_detail = null;

            try
            {
                foreach (GridViewRow gvRow in GridView1.Rows)
                {
                    chkSelect = (CheckBox)gvRow.FindControl("chkSelect");
                    var select = Request.Form[chkSelect.UniqueID];
                    if (select != null && select == "on")
                    {
                        lblrecv_item_code        = (Label)gvRow.FindControl("lblrecv_item_code");
                        lblrecv_item_name        = (Label)gvRow.FindControl("lblrecv_item_name");
                        txtrecv_item_rate        = (AwNumeric)gvRow.FindControl("txtrecv_item_rate");
                        chkRecv_item_is_director = (CheckBox)gvRow.FindControl("chkRecv_item_is_director");
                        var recv_item_rate = decimal.Parse(txtrecv_item_rate.Value.ToString());
                        deduct_detail = new Deduct_detail
                        {
                            deduct_doc_no           = ViewState["deduct_doc"].ToString(),
                            recv_item_code          = lblrecv_item_code.Text,
                            recv_item_rate          = recv_item_rate,
                            deduct_item_amount      = decimal.Parse(ViewState["recv_total_amount"].ToString()) * recv_item_rate / 100,
                            deduct_item_is_director = chkRecv_item_is_director.Checked,
                            c_created_by            = strUpdatedBy
                        };
                        oDeduct.SP_DEDUCT_DETAIL_INS(deduct_detail);
                    }
                    blnResult = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            finally
            {
                oDeduct.Dispose();
            }
            return(blnResult);
        }