private void DataSave() { #region Data string itemtype = cmbType.Text.GetDBFormatString(); string itemName = txtItemName.Text.GetDBFormatString(); string categoryid = cmbCategory.Text.ISNullOrWhiteSpace() ? "NULL" : ((KeyValuePair <string, string>)cmbCategory.SelectedItem).Key.ToString(); string hsnorsaccode = cmbComodityNo.Text.GetDBFormatString(); string gstrate = "NULL"; string cessrate = "NULL"; string unitcode = "NULL"; string naration = "NULL"; string cgst = "NULL"; string sgst = "NULL"; string igst = "NULL"; string CompanyNAme = txtCompanyNAme.Text.GetDBFormatString(); string templateName = txtTemplatNAme.Text.GetDBFormatString(); string subcategory = cmbSubCategory.Text.GetDBFormatString(); if (cmbType.Text == "Goods") { unitcode = ((KeyValuePair <string, string>)cmbUnit.SelectedItem).Key.ToString(); } if (!txtNaration.Text.ISNullOrWhiteSpace()) { naration = "'" + txtNaration.Text.GetDBFormatString() + "'"; } if (!txtCESSRate.Text.ISNullOrWhiteSpace()) { cessrate = "'" + txtCESSRate.Text.GetDBFormatString() + "'"; } if (!cmbGstRate.Text.ISNullOrWhiteSpace()) { gstrate = "'" + cmbGstRate.Text.GetDBFormatString() + "'"; } if (!txtCgst.Text.ISNullOrWhiteSpace()) { cgst = "'" + txtCgst.Text.GetDBFormatString() + "'"; } if (!txtSgst.Text.ISNullOrWhiteSpace()) { sgst = "'" + txtSgst.Text.GetDBFormatString() + "'"; } if (!txtIGst.Text.ISNullOrWhiteSpace()) { igst = "'" + txtIGst.Text.GetDBFormatString() + "'"; } bool isRCM = chkRCM.Checked; bool isITC = chkITC.Checked; #endregion string query = ""; if (!mItemIDForEdit.ISNullOrWhiteSpace()) { query = "Update item set itemName='" + templateName + "',itemType='" + itemtype + "',Categoryid=" + categoryid + ",ComodityCode='" + hsnorsaccode + "',GSTRate=" + gstrate + ",CessRate=" + cessrate + ",CGSTRate=" + cgst + ",sGSTRate=" + sgst + ",UnitId=" + unitcode + ",Narration=" + naration + ",IGSTRATE=" + igst + ",Company='" + CompanyNAme + "',TemplateName='" + itemName + "',SubCategory='" + subcategory + "',IsRCM='" + isRCM + "',IsITC='" + isITC + "' " + "where id='" + mItemIDForEdit + "' "; } else { query = "Insert into item(itemName,itemType,Categoryid,ComodityCode,GSTRate, " + "CessRate,CGSTRate,sGSTRate,UnitId,Narration,IGSTRATE,Company, " + "TemplateName,SubCategory,IsRCM,IsITC) values('" + templateName + "','" + itemtype + "'," + categoryid + "," + "'" + hsnorsaccode + "'," + gstrate + "," + cessrate + "," + cgst + "," + sgst + "," + unitcode + "," + naration + "," + igst + ",'" + CompanyNAme + "','" + itemName + "','" + subcategory + "','" + isRCM + "','" + isITC + "')"; } if (SQLHelper.GetInstance().ExcuteQuery(query, out msg)) { ItemTools.GetItem(); ItemTools.GetItemCategory(); ItemTools.GetSubCategory(); ItemTools.GetItemCompany(); this.Close(); } else { MessageBox.Show("Internal error. \n" + msg, "Save", MessageBoxButtons.OK, MessageBoxIcon.Error); } }